<?php
class STE_Member extends STE_Db
{
	public function checkLogin($email, $password)
	{
		try
		{
			$query = sprintf("CALL sp_admin_check_login('%s', '%s')", $email, md5($password));
			$member = $this->_db->fetchRow($query);
			$this->_db->closeConnection();
			return $member;
		}
		catch (Exception $ex)
		{
			throw $ex;
		}
	}
	
	public function getMember($memberID)
	{
		try {
			$query = "CALL sp_member_get_member(?)";
			$stmt = $this->_db->query($query, $memberID);
			$r = $stmt->fetchAll();
			return empty($r) ? null : $r[0];			
		} catch (Exception $e) {
			throw $e;
		}
	}
	
	public function changePassword($email, $currentPassword, $newPassword){
		try {
			$query = "CALL sp_member_update_password(?, ?, ?)";
			$stmt = $this->_db->query($query, array($email, md5($currentPassword), md5($newPassword)));
			return $result = $stmt->execute();
		} catch (Exception $e) {
			throw $e;
		}
	}
}	
?>